package com.mbc.common.manager;

import java.sql.Connection;

import com.mbc.common.dao.DBManager;
import com.mbc.common.dao.DBManagerFactory;

public abstract class AbstractMgr {
	protected String sessionId = "";
	protected DBManager dbManager;
	
	protected void openConnection() throws Exception
	{
		try {
			if(sessionId.equals(""))
				dbManager = DBManagerFactory.getDBManager();
			else
				dbManager = DBManagerFactory.getDBManager(sessionId);
		} catch (Exception e) {
			throw e;
		}
	}
	
	protected void openConnection(int linkType) throws Exception
	{
		try {
			if(sessionId.equals(""))
				dbManager = DBManagerFactory.getDBManager(linkType);
			else
				dbManager = DBManagerFactory.getDBManager(sessionId, linkType);
		} catch (Exception e) {
			throw e;
		}
	}
	
	protected Connection getConnection(){
		return dbManager.getConnection();
	}
	
	protected void closeConnection(){
		dbManager.closeConnection();
	}
	
	protected void beginTransaction(){
		dbManager.beginTransaction();
	}
	
	protected void commintTransaction(){
		dbManager.commitTransaction();
	}
	
	protected void rollbackTransaction(){
		dbManager.rollBackTransaction();
	}
}
